<?php

class IndexController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
    }

    public function indexAction() {        
        $validation = new Validations_User();
        if ($validation->hasidentity()) {
            $id = $validation->getUserId();
            $user = new Users_Model_Users();
            $details = $user->getUserById($id);
            if ($details[0]['name'] != null) {
                $name = $details[0]['name'];
            }else{
                $name= '';
            }
            $decodedDetails = $user->getUserDetailsDecoded($details[0]['details']);
            $this->view->name = $name;
            $this->view->email = $details[0]['email'];
            $this->view->status = $details[0]['status'];
            $this->view->contact1 = $decodedDetails['contact1'];
            $this->view->contact2 = $decodedDetails['contact2'];
            $this->view->address = $decodedDetails['address'];
        } else {
            $this->_redirect('/user/login');
        }
    }

    public function test2Action() {        
//        $db2 = new Application_Model_Test();
//        $res = $db2->fetchall();
//        foreach ($res as $cmt) {
//            echo '<pre>';
//            $result = $cmt->findDependentRowSet('Application_Model_DbTable_Test2');
////            $result = $cmt->findParentRow('Application_Model_DbTable_Test');
//            print_r($result);
//            echo '</pre>';
//        }

//        $userDb = new Users_Model_Users();
//        $result = $userDb->getUserByType('user');
//        foreach ($result as $user) {
//            $output = $user->findDependentRowSet('Comments');
//            echo '<pre>';
//            print_r($user);
//            echo '</pre>';
//        }
               
    }

}

